<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Generator" content="ALORK 20150428.01" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="<?php echo $this->_var['keywords']; ?>" />
<meta name="Description" content="<?php echo $this->_var['description']; ?>" />

<title><?php echo $this->_var['page_title']; ?></title>

<?php if ($this->_var['cat_style']): ?>
<link href="<?php echo $this->_var['cat_style']; ?>" rel="stylesheet" type="text/css" />
<?php endif; ?>
<link rel="stylesheet" href="<?php echo $this->_var['ecs_css_my']; ?>" />
<link rel="stylesheet" href="<?php echo $this->_var['ecs_css_path']; ?>" />
<link rel="stylesheet" href="<?php echo $this->_var['__PUC__']; ?>css/common.css" />
  <?php echo $this->smarty_insert_scripts(array('files'=>'common.js')); ?>
</head>
<body >
	<?php echo $_SESSION['agent_rank']; ?>
	<?php echo $this->fetch('library/page_header.lbi'); ?>

	<script type="text/javascript">

// 商品图片变换
    $(function(){
      $("#goods .photo .thumb img").mouseenter(function(){
        $(this).parent().find(".thumb_top").addClass("thumb_top_b").parent().siblings().find(".thumb_top").removeClass('thumb_top_b');
        $("#goods .photo .big_img img").attr("src",$(this).attr("big"));
        $("#goods .body .none img").attr("src",$(this).attr("original"));
        $('#magnifier_pic .magnifier_pic img').attr("src",$(this).attr("original"));
        // $("#goods .body .magnifier_pic img").attr("src",$(this).attr("original"));
      });     
    });
    // 放大镜JS
    $(document).ready(function(){

      var img=444;//定义区域大小
    var xOffset = 111;//定义x的偏移量
      var yOffset = 111;//定义y的偏移量
    $("#goods .photo .big_img img").mouseenter(function(){
      var ran = 'pic'+Math.floor(Math.random()*10000+1);
      $("#goods .body.photo").prepend('<div class="'+ran+'">'+$('#magnifier_pic').html()+'</div>');
      $("#goods .photo .big_img .magnifier").show();
      $("#goods .body ."+ran+" .magnifier_pic").animate({
        height:'400px',
        width:'400px',
        marginTop:"27px",
        marginRight:"200px",
        opacity:'1'
        });
      $("#goods .photo .big_img").mouseleave(function(){
        $("#goods .photo .big_img .magnifier").hide();
        $("#goods .body ."+ran+" .magnifier_pic").animate({
          height:'0px',
          width:'0px',
          opacity:'0',
          marginTop:"200px",
          marginRight:"800px"
          },300);
          setTimeout(function(){removes(ran)},600);
        // $("#goods .body .magnifier_pic").hide();
      });
    });
    function removes(ran){
      $("#goods .body ."+ran).remove();
    }


  $("#goods .photo .big_img").mousemove(function(e){
    $("#goods .photo .big_img").css({"position":"relative"});
    $("#goods .body").css({"position":"relative"});
      var positionX=e.pageX-$(this).offset().left||e.originalEvent.layerX-$(this).offset().left||0;//获取当前鼠标相对img的x坐标
      var positionY=e.pageY-$(this).offset().top||e.originalEvent.layerY-$(this).offset().top||0;
      if(yOffset>positionY<(img-yOffset)){
        $("#goods .photo .big_img .magnifier").css("top",(positionY-yOffset));
      }
      if(positionY<yOffset){
        $("#goods .photo .big_img .magnifier").css("top",0);
      }
      if(positionY>(img-yOffset)){
        $("#goods .photo .big_img .magnifier").css("top",(img-yOffset*2));
      }

      if(xOffset>positionX<(img-xOffset)){
        $("#goods .photo .big_img .magnifier").css("left",(positionX-xOffset));
      }
      if(positionX<xOffset){
        $("#goods .photo .big_img .magnifier").css("left",0);
      }
      if(positionX>(img-xOffset)){
        $("#goods .photo .big_img .magnifier").css("left",(img-xOffset*2));
      }
      var left=parseInt($("#goods .photo .big_img .magnifier").css('left'));
      var top=parseInt($("#goods .photo .big_img .magnifier").css('top'));
// $("#goods .photo .big_img .magnifier").text("X: " + left + ", Y: " + top);
      
         $("#goods .body .magnifier_pic img").css("top",(-top*1.8)).css("left",(-left*1.8));
         if(top>268){
            $("#goods .body .magnifier_pic img").css("top",(-268*1.8)).css("left",(-left*1.8));
         }
    });
  });

</script>

	<div class="goods_top"></div>
	<div style="width: 100%;float: left;">
	<div id="goods" class="body">
	<div class="body">
		<div id="magnifier_pic"><div class="magnifier_pic"><img src="images/defaultico.gif" class="loadimg loadbg" data-original="<?php echo $this->_var['pictures']['0']['img_original']; ?>"/></div></div>
		<div class="box_top">
		<div class="photo">
			<div class="big_img" >
				<div class="magnifier"></div>
				  <img src="images/defaultico.gif" class="loadimg" data-original="<?php echo $this->_var['pictures']['0']['img_url']; ?>" alt="<?php echo htmlspecialchars($this->_var['goods']['goods_name']); ?>"/>
			</div>
			<div class="thumb">
			    <?php $_from = $this->_var['pictures']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'picture');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['picture']):
?>
	            <a href="javascript:void();" target="_blank">
					<?php if ($this->_var['key'] == 0): ?>
	            	<span class="thumb_top thumb_top_b"></span>
	            	<?php else: ?>
	            	<span class="thumb_top"></span>
					<?php endif; ?>
	            	<img src="images/defaultico.gif" data-original="<?php if ($this->_var['picture']['thumb_url']): ?><?php echo $this->_var['picture']['thumb_url']; ?><?php else: ?><?php echo $this->_var['picture']['img_url']; ?><?php endif; ?>" big="<?php echo $this->_var['picture']['img_url']; ?>" original="<?php echo $this->_var['picture']['img_original']; ?>" alt="<?php echo $this->_var['goods']['goods_name']; ?>" class="B_blue loadimg" /></a>   
	            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
			</div>
			<a href="javascript:collect(<?php echo $this->_var['goods']['goods_id']; ?>)" class="thumb_bttom">
				加入收藏
			</a>

		</div>
		<div class="info">
			<div class="clearfix title"><?php echo $this->_var['goods']['goods_name']; ?></div>
        <?php if ($this->_var['goods']['is_promote'] && $this->_var['goods']['gmt_end_time']): ?>
	        <div class="promote_price">
	        	<div class="name">闪购价</div>
	        	<div class="shop_price">
	        		<?php echo $this->_var['goods']['promote_price']; ?>
	        	</div>
	        	<div class="eleven">
	        		<span  style="text-decoration: line-through;">市场价<?php echo $this->_var['goods']['market_price']; ?></span>
	        	</div>
	        </div>
	        <div class="time">
	        	TIME：剩余时间  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="promote_time" time="<?php echo $this->_var['end_time']; ?>"><?php echo $this->_var['end_time_now']; ?></span>
	        </div>

		<?php elseif ($this->_var['goods']['is_new'] == 1 && $this->_var['goods']['is_best'] == 0): ?>
	        <div class="by_your_price_price">
	        	<div class="left">
	        		<span class="text">由你定价</span>
	        		<span class="shop_price"><?php echo $this->_var['goods']['shop_price']; ?></span>
	        	</div>
	        	<div class="right">
	        		<span class="text">原价</span>
	        		<span class="market_price"><?php echo $this->_var['goods']['market_price']; ?></span>
	        	</div>
				<div class="discount"><?php echo $this->_var['goods']['discount']; ?>折</div>
	        </div>

        <?php elseif ($this->_var['goods']['preferential_price'] > 0 && $this->_var['goods']['preferential_num']): ?>
	        <div class="eleven_price">
	        	<div class="shop_price">
	        		<?php if (( $this->_var['user_array']['agent_rank'] == 1 || $this->_var['user_array']['agent_rank'] == 2 ) && $this->_var['goods']['agent_price'] > 0): ?>
	        		<span title="分销价" class="one"><?php echo $this->_var['goods']['agent_price']; ?></span>
	        		<?php else: ?>
	        		<span class="one"><?php echo $this->_var['goods']['shop_price']; ?></span>
	        		<?php endif; ?>
	        	</div>
	        	<div class="eleven">
	        		<span class="two" style="text-decoration: line-through; color: #acacac;"><?php echo $this->_var['goods']['market_price']; ?></span>
	        	</div>
				<div class="preferential">
					<span>￥</span><?php echo $this->_var['goods']['preferential_price']; ?>
				</div>
	        </div>
	    <?php else: ?>
	        <div class="eleven_price eleven_price2">
	        	<div class="shop_price">
	        		<span class="one">　鸡蛋优惠价　<?php echo $this->_var['goods']['shop_price']; ?></span>
	        	</div>
	        	<div class="eleven">
	        		　正品市场价　 <span class="two" style="text-decoration: line-through;"><?php echo $this->_var['goods']['market_price']; ?></span>
	        	</div>
	        </div>
		<?php endif; ?>
	        <script type="text/javascript">

		      $(function(){
		        var i=0;
		        var arr=Array();
		          var inter=setInterval(function(){
		              $("#promote_time").text(datetime($("#promote_time").attr("time")));

		          },1000);
		      });
		      function datetime(time1){
		        var time = time1-1;
		        $("#promote_time").attr("time",time);
		        var Y='';
		        var D='';
		        var H='';
		        var M='';
		        var T='';
		        if(Math.floor((time/3600)/24)!=0){
		          D=Math.floor((time/3600)/24)+":";
		        }else if(Y!=''){
		          D=0+":";
		        }
		        if(Math.floor((time/3600)%24)!=0){
		          H=Math.floor((time/3600)%24)+":";
		        }else if(D!=''){
		          H=0+":";
		        }
		        if(Math.floor((time%(3600))/60)!=0){
		          M=Math.floor((time%(3600))/60)+":";
		        }else if(H!=''){
		          M=0+":";
		        }
		        if(Math.floor(time%(60))!=0){
		          T=Math.floor(time%(60))+"";
		        }else if(M!=''){
		          T=0+":";
		        }
		        return Y+D+H+M+T;
		      }
		    </script>

			
			<?php if ($this->_var['goods']['is_new'] == 1 && $this->_var['goods']['is_best'] == 1): ?>
			<div class="by_your_pricing"></div>
			<a href="http://weibo.com/u/1764928933" target="_blank"><div class="go_now">立即参加</div></a>
			<?php elseif ($this->_var['goods']['is_new'] == 1): ?>
			<div class="goods_over_by_your_price"></div>
			<?php $_from = $this->_var['by_your_pricing_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'item');if (count($_from)):
    foreach ($_from AS $this->_var['item']):
?>
			<div class="new_by_your_pricing"><a href="<?php echo $this->_var['item']['url']; ?>" target="_blank">#<?php echo $this->_var['item']['goods_name']; ?>#</a>正在参与微博互动游戏，赶快前往支援</div>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
			<div class="goods_over_by_your_price2"></div>
			<?php else: ?>
			<div class="clearfix integral">
				<li><span style="color: #8b0409"><?php echo $this->_var['Sales']; ?></span></br><span style="color: #c2c2c2">销量</span></li>
				<li><span style="color: #8b0409"><?php echo $this->_var['pager']['record_count']; ?></span></br><span  style="color: #c2c2c2">评价</span></li>
				<li><span style="color: #8b0409"><?php echo $this->_var['goods']['give_integral']; ?></span></br><span  style="color: #c2c2c2">积分</span></li>
			</div>
			<!-- <div class="clearfix baoyou"></div> -->
			<!-- <div class="clearfix" style="color:#ab0409; font-weight: bolder; font-size:14px;display: block;">520当天全场买100送50,买300送150,买500送300</div> -->
			<div class="clearfix"><span class="left">评分：</span><span class="rank"><span class="rank_this" style="width:<?php echo $this->_var['goods']['comment_rank']; ?>%"></span></span></div>
			<?php endif; ?>

			<div class="clearfix peisong"><span class="left">配送至：</span>
                <?php 
$k = array (
  'name' => 'category_area',
);
echo $this->_echash . $k['name'] . '|' . serialize($k) . $this->_echash;
?>
			</div>

			<div class="Property">
		    	<li id="goods_buy" class="left">
				<?php if ($this->_var['related_goods']): ?>
						<div class="clearfix">颜色分类：</div>
				     	<?php $_from = $this->_var['related_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'item');if (count($_from)):
    foreach ($_from AS $this->_var['item']):
?>
				        <a <?php if ($this->_var['goods_id'] != $this->_var['item']['goods_id']): ?> onclick="javascript:buy_html('<?php echo $this->_var['item']['url']; ?>');"<?php endif; ?> class="left spec<?php if ($this->_var['goods_id'] == $this->_var['item']['goods_id']): ?> this<?php endif; ?>" title="<?php echo $this->_var['item']['goods_name']; ?>"><?php echo $this->_var['item']['goods_brief']; ?></a>
				        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
				<?php endif; ?>

					    <?php $_from = $this->_var['specification']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('spec_key', 'spec');if (count($_from)):
    foreach ($_from AS $this->_var['spec_key'] => $this->_var['spec']):
?>
					    <div class="left" style="width: 100%">
					    <div class="clearfix"><strong id="spec_name" style="color:#8b0409"><?php echo $this->_var['spec']['name']; ?>：</strong><br /></div>
					    <div class="color_border">
					    	<div class="bl"></div>
					    	<div class="b">
					    		<div class="ul">
	                        <?php $_from = $this->_var['spec']['values']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'value');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['value']):
?>
							<?php if ($this->_var['spec']['name'] == '颜色'): ?>
							
							<div class="bb<?php if ($this->_var['key'] == 0): ?> hover<?php endif; ?><?php if ($this->_var['value']['text_color']): ?> black<?php endif; ?>" style="background: <?php echo $this->_var['value']['color']; ?>;" name="<?php echo $this->_var['value']['label']; ?>">
								<span class="text"><?php echo $this->_var['value']['label']; ?></span><br />
								<span class="button">
									<span class="next"></span>
									<span class="color_num"><input type="text" class="color_input isnumber" value="0" /></span>
									<span class="pre"></span>
								</span>
								<input type="hidden" class="goods_stock" value="<?php echo empty($this->_var['value']['goods_number']) ? 0 : $this->_var['value']['goods_number']; ?>" />
								<input type="hidden" class="spec_id <?php echo $this->_var['value']['id']; ?>" name="spec_id" value='<?php echo $this->_var['value']['id']; ?>' />
								<input type="hidden" class="goods_id" name="goods_id" value='<?php echo $this->_var['goods_id']; ?>' />
							</div>
							
							<?php endif; ?>
	                        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
							</div>
							</div>
							<div class="br"></div>
						</div>
							<br />
					    </div>
					    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
					    
				</li>
			</div>
	    	<form action="" method="post" name="ECS_FORMBUY" id="ECS_FORMBUY" >
	    	<input type="hidden" id="buy_goods_html" class="buy_goods_html" name="buy_goods_html" value='' />
	    	<input type="hidden" id="goods_number" value='<?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>' />
			<?php if ($this->_var['specification']['1']['name'] == '颜色'): ?>
			
			<div class="clearfix" id="goods_num">
				数量：<span id="count_nums">0</span>
			</div>
			<?php else: ?>
			<div class="clearfix" id="num"><span class="left">数量</span>
				<span class="button">
					<span class="pre">-</span>
					<span class="color_num">
						<input id="alork_num" name="number" type="text" value="0" size="4" onblur="changePrice()" class="color_input isnumber"/></span>
					<span class="next">+</span>
				</span>
			</div>
			<?php endif; ?>
			<?php if ($this->_var['related_goods'] || $this->_var['specification']): ?>
			<div class="buy_goods <?php if (! $this->_var['buy_goods']): ?> none<?php endif; ?>">
				<div>已选购</div>
				<div class='html'>
					<?php $_from = $this->_var['buy_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'buy_goods');if (count($_from)):
    foreach ($_from AS $this->_var['buy_goods']):
?>
						<span id="<?php echo $this->_var['buy_goods']['0']; ?><?php echo $this->_var['buy_goods']['1']; ?>" goods_id="<?php echo $this->_var['buy_goods']['0']; ?>" class="<?php echo $this->_var['buy_goods']['1']; ?>"><a class="name"><?php echo $this->_var['buy_goods']['3']; ?></a><a class="pre none" onclick="buy_goods_button($(this),1)"></a><a class="input"><input type="text" name="" class='isnumber' value="<?php echo $this->_var['buy_goods']['2']; ?>" style="color: #db1f50;" onfocus="buy_goods_button($(this),2);"></a><a class="next none" onclick="buy_goods_button($(this),3)"></a><a style="color: #db1f50;" class="close" onclick='buy_goods_button($(this),4)'></a></span>
					<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
				</div>
			</div>
			<?php endif; ?>
			<?php if (( $this->_var['goods']['goods_number'] > 0 || $this->_var['specification'] ) && $this->_var['is_buy']): ?>
			<li class="padd" style="position:relative;" >
				<a <?php if (! $_SESSION['user_id']): ?>onclick="ajax_popup('login');"<?php else: ?> href="javascript:alork_addcart(<?php echo $this->_var['goods']['goods_id']; ?>,1)"  <?php endif; ?>   id="goods_submit" class="button_2">立即购买</a>
				<a <?php if (! $_SESSION['user_id']): ?>onclick="ajax_popup('login');"<?php else: ?> href="javascript:alork_addcart(<?php echo $this->_var['goods']['goods_id']; ?>,0)"  <?php endif; ?>  class="button_2">加入购物车</a>
				<div id="gwc"></div>
			</li>
			<?php else: ?>
			<li class="padd" style="position:relative;" >
				<a id="goods_submit" class="button_2 notbuy">立即购买</a>
				<a class="button_2 notbuy">加入购物车</a>
				<div id="gwc" style="color: #8b0409;width: 100%;float: left;">
					<?php if ($this->_var['is_buy']): ?>抱歉！此商品已售罄！<?php else: ?>抱歉！试营阶段此地区暂时没开放货到付款服务！敬请期待！<?php endif; ?></div>
			</li>
			<?php endif; ?>
			<div class="Share">
				喜欢这件画材吗？ <a href="<?php echo $this->_var['goods']['share_url']; ?>" style="color: #8b0409" target="_blank">分享</a>给你的朋友吧<span style="color: #8b0409">！！</span>分享到微博<a href="<?php echo $this->_var['goods']['share_url']; ?>" class="share_ico" target="_blank"></a>
			</div>
			</form>
		</div>
		</div>
		<div class="more">
			<?php echo $this->fetch('library/history.lbi'); ?>
		</div>
		<div class="main">
			<div class="nav">
				<ul>
					<li class="hover">商品信息</li>
					<li>用户评论(<?php echo $this->_var['pager']['record_count']; ?>)</li>
					<li>购买记录(<?php echo $this->_var['count']; ?>)</li>
				</ul>
			</div>

			<div class="box1 box">
			<script type="text/javascript">
			var goods_desc = '<?php echo $this->_var['goods']['goods_desc']; ?>';
			$(function(){
				$('.box1').html(goods_desc);
			});
			</script>
			</div>
			<div class="box2 box" id="ECS_COMMENT">
				<?php echo $this->fetch('library/comments.lbi'); ?>
			</div>
		     <div class="box3 box">
				<?php echo $this->fetch('library/bought_note_guide.lbi'); ?>
		    </div>

		</div>

	</div>
 </div>
</div>
	<?php echo $this->fetch('common/page_footer.lbi'); ?>
	<?php echo $this->fetch('common/follow_right.lbi'); ?>
<script type="text/javascript">
// 商品内容页详情选择器
	$(function(){
		$("#goods .main .nav li").click(function(){
			$(this).siblings().removeClass("hover");
			$(this).addClass("hover");
			$("#goods .main .box").hide();
			$("#goods .main .box").eq($(this).index()).show();
		});
	});

// 颜料商品颜色选择器
	$(function(){

		// 颜料数量初始化
		var number=0;
		$(".buy_goods .html span").each(function(){
			number = number+parseInt($(this).find('input').val());
		});
        $("#count_nums").html(number);


        // 规格数量初始化
        if($('#num input').length>0){
	        $('#num input').val($('#<?php echo $this->_var['goods_id']; ?> input').val()?$('#<?php echo $this->_var['goods_id']; ?> input').val():0);
        }

        // 颜料切换数量回调
        if($(".buy_goods .html span").length>0){
			$(".buy_goods .html span").each(function(){
	        	if($(this).attr('class')){
		        	$("#goods_buy .color_border ."+$(this).attr('class')).parent().find('.button input').val($(this).find('input').val());
	        	}
			});
        }

        // 颜料滚动
		$('#goods_buy .b .ul').css('width',($("#goods_buy .bb").length*23+70)+'px');
		$("#goods_buy .bb").mouseenter(function(){
			$(this).addClass('hover').siblings().removeClass('hover');
		});
		$("#goods_buy .bl").click(function(){
			$('#goods_buy .b').scrollLeft($('#goods_buy .b').scrollLeft()-345);
			$("#goods_buy .bb").eq($('#goods_buy .b').scrollLeft()/23).addClass('hover').siblings().removeClass('hover');
		});
		$("#goods_buy .br").click(function(){
			$('#goods_buy .b').scrollLeft($('#goods_buy .b').scrollLeft()+345);
			$("#goods_buy .bb").eq($('#goods_buy .b').scrollLeft()/23).addClass('hover').siblings().removeClass('hover');
		});


		// 颜料数量选择器
		$("#goods_buy .button").find(".pre").click(function(){
			var num=parseInt($(this).siblings(".color_num").find(".color_input").val());
			var number=0;
			if(num-1<0){num=0}else{num-=1}
			$(this).siblings(".color_num").find(".color_input").val(num);
			$("#count_nums").html("0");
  			color_num($(this));
			$(".buy_goods .html span").each(function(){
				number = number+parseInt($(this).find('input').val());
			});
            $("#count_nums").html(number);
		});

		$("#goods_buy .button").find(".color_input").blur(function(){
			$("#count_nums").html("0");
			var number=0;
			var num = parseInt($(this).val());
			var goods_number = parseInt($(this).parents('.bb').find(".goods_stock").val());
			if(num > goods_number){
				num = goods_number;
				Ctf_ctock_remind(goods_number,<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
			}
			$(this).val(num);
			color_num($(this).parent());
			$(".buy_goods .html span").each(function(){
				number = number+parseInt($(this).find('input').val());
			});
            $("#count_nums").html(number);
		});
		$("#goods_buy .button").find(".next").click(function(){
			var num=parseInt($(this).siblings(".color_num").find(".color_input").val());
			var number=0;
			num+=1;
			var goods_number = parseInt($(this).parents('.bb').find(".goods_stock").val());
			if(num > goods_number){
				num = goods_number;
				Ctf_ctock_remind(goods_number,<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
			}
			$(this).siblings(".color_num").find(".color_input").val(num);
			$("#count_nums").html("0");
			color_num($(this));
			$(".buy_goods .html span").each(function(){
				number = number+parseInt($(this).find('input').val());
			});
            $("#count_nums").html(number);
		});


		// 规格数量选择器
		$("#num .button .pre").click(function(){
			var num=$("#alork_num").val();
			if (parseInt(num)>1) {
				num=parseInt(num)-1;
				$("#alork_num").val(num);
				spec_num(num);
			};
		});
		$("#num .button .next").click(function(){

			var num=$("#alork_num").val();
			num=parseInt(num)+1;
			if(num><?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>)
			{	
				num = <?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>;
				<?php if ($this->_var['goods']['is_promote'] && $this->_var['goods']['gmt_end_time']): ?>
				Ctf_ctock_remind2('<?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>',<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
				<?php else: ?>
				Ctf_ctock_remind('<?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>',<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
				<?php endif; ?>
			}
			$("#alork_num").val(num);
			spec_num(num);
		});

		// 选择数量
		$("#num .button .color_num input").blur(function(){
			num=parseInt($("#alork_num").val());//获取用户输入数量
			if(num><?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>)
			{
				num = <?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>;
				<?php if ($this->_var['goods']['is_promote'] && $this->_var['goods']['gmt_end_time']): ?>
				Ctf_ctock_remind2('<?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>',<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
				<?php else: ?>
				Ctf_ctock_remind('<?php echo empty($this->_var['goods']['goods_number']) ? 0 : $this->_var['goods']['goods_number']; ?>',<?php echo $this->_var['goods']['goods_id']; ?>,<?php echo $this->_var['goods']['cat_id']; ?>);
				<?php endif; ?>
			}
			spec_num(num);
		});



		// 颜料已选购
	    function color_num(obj){
	    	var html="";
	    	var val=$(obj).parent().find(".color_num").find(".color_input").val();;
			if(val > 0){
				var name = $(obj).parent().parent().attr('name');
				var spec_id = $(obj).parent().parent().find('.spec_id').val();
				var goods_id = $(obj).parent().parent().find('.goods_id').val();
				html = "<span id='"+goods_id+spec_id+"' goods_id='"+goods_id+"' class='"+spec_id+"'><a class='name'>"+name+"</a><a class='pre none' onclick='buy_goods_button($(this),1)'></a><a class='input'><input type='text' name='' value='"+val+"' style='color: #db1f50;' onblur='buy_goods_button($(this),5);' onfocus='buy_goods_button($(this),2);'></a><a class='next none' onclick='buy_goods_button($(this),3)'></a><a style='color: #db1f50;' class='close' onclick='buy_goods_button($(this),4);'></a></span>";
				if($('#'+goods_id+spec_id).length>0){
					$('#'+goods_id+spec_id).after(html).remove();
				}else{
					$(".buy_goods").show().find('.html').append(html);
				}
			}
	    }

	    // 规格已选购
	    function spec_num(val){
	    	if(val>0){
				var name = $('#goods_buy .left.spec.this').text();
				var spec_id = '';
				var goods_id = <?php echo $this->_var['goods_id']; ?>;
				html = "<span id='"+goods_id+spec_id+"' goods_id='"+goods_id+"' class='"+spec_id+"'><a class='name'>"+name+"</a><a class='pre none' onclick='buy_goods_button($(this),1)'></a><a class='input'><input type='text' name='' value='"+val+"' style='color: #db1f50;' onblur='buy_goods_button($(this),5);' onfocus='buy_goods_button($(this),2);'></a><a class='next none' onclick='buy_goods_button($(this),3)'></a><a style='color: #db1f50;' class='close' onclick='buy_goods_button($(this),4);'></a></span>";
				if($('#'+goods_id+spec_id).length>0){
					$('#'+goods_id+spec_id).after(html).remove();
				}else{
					$(".buy_goods").show().find('.html').append(html);
				}
	    	}
	    }
	});

	// 已选购控制器
	function buy_goods_button(obj, val){
		var num = parseInt($(obj).siblings('.input').find('input').val());
		if(val == '1'){
			if(num-1>0){
				num -= 1;
				$(obj).siblings('.input').find('input').after("<input type='text' name='' value='"+num+"' >").remove();
			}else{
				$(obj).parent().remove();
			}
		}else if(val == '3'){
			num += 1;
			$(obj).siblings('.input').find('input').after("<input type='text' name='' value='"+num+"' >").remove();
		}else if(val == '2'){
			$(obj).parent().parent().parent().find('.pre,.next').hide();
			$(obj).parent().siblings().show();
		}else if(val == '4'){
			var spec_id = $(obj).parent().attr('class');
			$('.spec_id.'+spec_id).parent().find('.color_input').val(0);
			$(obj).parent().remove();
			if(!$('.buy_goods .html span').length){
				$('.buy_goods').hide();
			}
		}else{
			$(obj).parent().parent().parent().find('.pre,.next').hide();
		}
		var number=0;
		$(".buy_goods .html span").each(function(){
			number = number+parseInt($(this).find('input').val());
		    spec_id = $(this).attr('class');
		    $("#goods_buy .color_border ."+spec_id).parent().find('.color_input').val(parseInt($(this).find('input').val()));
		});
        $("#count_nums").html(number);
	}


	// 关联切换
	function buy_html(url){
		if($('.buy_goods .html span').length>0){
			var goods_id = '';
			var spec_arr = '';
			var number = '';
			var name = '';
			$(".buy_goods .html span").each(function(){
				goods_id = goods_id+$(this).attr('goods_id')+'-';
				spec_arr = spec_arr+$(this).attr('class')+'-';
				number = number+$(this).find('input').val()+'-';
				name = name+$(this).find('.name').text()+'-';
			});
			var html = goods_id+'/'+spec_arr+'/'+number+'/'+name;
			$('#buy_goods_html').val(html);
			$('#ECS_FORMBUY').attr('action',url).submit();
		}else{
			location.href=url;
		}
	}
	
	// 加入购物车
	function alork_addcart(id,num){
		if($(".buy_goods .html span").length>0 || $('.color_border .bb').length>0){
			var goods_id = '';
			var spec_arr = '';
			var number = '';
			if($(".buy_goods .html span").length<1){
				var html='<div class="color_notice" style="width: 493px;height: 168px;position: absolute;left: 0px;top: 5px;border: 1px solid red;opacity: 0;box-shadow: 0 0 4px red inset;"></div>'
				$('#goods .color_border').append(html);
				$('#goods .color_notice').animate({opacity: 1},300,function(){
					$('#goods .color_notice').animate({opacity: 0},300,function(){
						$('#goods .color_notice').remove();
					});
				});
				return false;
			};
			$(".buy_goods .html span").each(function(){
				goods_id = goods_id+$(this).attr('goods_id')+'-';
				spec_arr = spec_arr+$(this).attr('class')+'-';
				number = number+$(this).find('input').val()+'-';
				$('.spec_id.'+$(this).attr('class')).siblings('.goods_stock').val($('.spec_id.'+$(this).attr('class')).siblings('.goods_stock').val()-parseInt($(this).find('input').val()));
			});
			addToCart(goods_id,spec_arr,number,'',num);
			$(".buy_goods").hide().find('.html').html('');
			$("#count_nums").text(0);
			$(".color_input").val(0);
		}else{
			addToCart(id,'',$('#alork_num').val(),'',num);
		}
	}


</script>

<script type="text/javascript">

// 商品图片变换
		$(function(){
			$("#goods .photo .thumb img").mouseenter(function(){
				$(this).parent().find(".thumb_top").addClass("thumb_top_b").parent().siblings().find(".thumb_top").removeClass('thumb_top_b');
				$("#goods .photo .big_img img").attr("src",$(this).attr("big"));
				$("#goods .body .none img").attr("src",$(this).attr("original"));
				$('#magnifier_pic .magnifier_pic img').attr("src",$(this).attr("original"));
				// $("#goods .body .magnifier_pic img").attr("src",$(this).attr("original"));
			});			
		});
		// 放大镜JS
		$(document).ready(function(){
			$(".mores").toggle(
				function(){
				    $(".color_border").css("height","auto");
				    $(this).addClass("mores1");
				},
				    function(){
				    $(".color_border").css("height","125px");
				    $(this).removeClass("mores1");
				}
			);

	    var img=444;//定义区域大小
	 	var xOffset = 111;//定义x的偏移量
    	var yOffset = 111;//定义y的偏移量
		$("#goods .photo .big_img img").mouseenter(function(){
			var ran = 'pic'+Math.floor(Math.random()*10000+1);
			$("#goods .body").prepend('<div class="'+ran+'">'+$('#magnifier_pic').html()+'</div>');
			$("#goods .photo .big_img .magnifier").show();
			$("#goods .body ."+ran+" .magnifier_pic").animate({
    		height:'400px',
    		width:'400px',
    		marginTop:"27px",
    		marginRight:"100px",
    		opacity:'1'
  			});
			$("#goods .photo .big_img").mouseleave(function(){
				$("#goods .photo .big_img .magnifier").hide();
				$("#goods .body ."+ran+" .magnifier_pic").animate({
	    		height:'0px',
	    		width:'0px',
	    		opacity:'0',
	    		marginTop:"200px",
	    		marginRight:"800px"
	  			},300);
	  			setTimeout(function(){removes(ran)},600);
				// $("#goods .body .magnifier_pic").hide();
			});
		});
		function removes(ran){
			$("#goods .body ."+ran).remove();
		}




	$("#goods .photo .big_img").mousemove(function(e){
		$("#goods .photo .big_img").css({"position":"relative"});
		$("#goods .body").css({"position":"relative"});
	    var positionX=e.pageX-$(this).offset().left||e.originalEvent.layerX-$(this).offset().left||0;//获取当前鼠标相对img的x坐标
	    var positionY=e.pageY-$(this).offset().top||e.originalEvent.layerY-$(this).offset().top||0;
			if(yOffset>positionY<(img-yOffset)){
				$("#goods .photo .big_img .magnifier").css("top",(positionY-yOffset));
			}
			if(positionY<yOffset){
				$("#goods .photo .big_img .magnifier").css("top",0);
			}
			if(positionY>(img-yOffset)){
				$("#goods .photo .big_img .magnifier").css("top",(img-yOffset*2));
			}

			if(xOffset>positionX<(img-xOffset)){
				$("#goods .photo .big_img .magnifier").css("left",(positionX-xOffset));
			}
			if(positionX<xOffset){
				$("#goods .photo .big_img .magnifier").css("left",0);
			}
			if(positionX>(img-xOffset)){
				$("#goods .photo .big_img .magnifier").css("left",(img-xOffset*2));
			}
			var left=parseInt($("#goods .photo .big_img .magnifier").css('left'));
			var top=parseInt($("#goods .photo .big_img .magnifier").css('top'));
// $("#goods .photo .big_img .magnifier").text("X: " + left + ", Y: " + top);
      
         $("#goods .body .magnifier_pic img").css("top",(-top*1.8)).css("left",(-left*1.8));
         if(top>268){
         	  $("#goods .body .magnifier_pic img").css("top",(-268*1.8)).css("left",(-left*1.8));
         }
		});
	});

</script>
</body>



</html>